import React from 'react';
import { Tools, Icon, ActionSheet, List, Button, TextareaItem } from 'weaver-mobile';
const getLabel = Tools.getLabel;
const FormItem = List.FormItem;

export const viewTodo = (data, setTodo, setComplete) => {
  const prefixCls = "email-todo-view";
  const remindCon = data.waitdealway == '5' ? getLabel('383607','消息中心提醒') : data.waitdealway == '1' ? getLabel('17586','短信提醒') : getLabel('510271','消息中心提醒，短信提醒')
  const content = (
    <div className={prefixCls}>
      <div className={`${prefixCls}-title`}>
        <div className={`${prefixCls}-title-left`}>
          <div className={`${prefixCls}-title-left-name`}>{getLabel(384330, '已设置为待办邮件')}</div>
          <div className={`${prefixCls}-title-left-time`}>
            {data.waitdealtime}{getLabel(553, '处理')}
          </div>
        </div>
        <div className={`${prefixCls}-title-right`} onClick={setTodo}>
          <Icon type="editor" size="sm" />
        </div>
      </div>
      <div className={`${prefixCls}-content`}>
        <List>
          {data.op_hasRemind === 1 ?
            <FormItem
              key='way'
              label={getLabel(18713, '提醒方式')}
              wrap='nowrap'
              line
              content={<div>{remindCon}</div>}
            /> :
            <List.Item
              arrow='horizontal'
              onClick={() => setTodo('addRemind')}
            >
              {getLabel(83135, '添加提醒')}
            </List.Item>
          }
          {data.op_hasRemind === 1 &&
            <FormItem
              key='time'
              label={getLabel(785, '提醒时间')}
              wrap='nowrap'
              line
              content={<div>{data.wdremindtime}</div>}
            />
          }
          {data.op_hasNote === 1 ?
            <FormItem
              key='note'
              label={'备注'}
              wrap='nowrap'
              line
              content={<TextareaItem value={data.waitdealnote} autoHeight />}
            /> :
            <List.Item
              arrow='horizontal'
              onClick={() => setTodo('addNote')}
            >
              {getLabel(83136, '添加备注')}
            </List.Item>
          }
        </List>
      </div>
      <div className={`${prefixCls}-button`}>
        <Button>{getLabel(31129, '取消')}</Button>
        <Button type="primary" onClick={setComplete}>{getLabel(83112, '设为完成')}</Button>
      </div>
    </div>
  );
  const BUTTONS = [{ content }];
  return ActionSheet.showActionSheetWithOptions({
    className: `${prefixCls}-actionSheet`,
    options: BUTTONS,
    maskClosable: true,
    'data-seed': 'logId',
    onTouchStart: e => e.preventDefault(),
  });
}